﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using TunnelClasses;

namespace Tunnel_Cross_Section.相关类
{
    public class Calibrate
    {
        private DataBase md;
        public double Cvalue { get; set; }
        public string DeviceNo { get; set; }
        private DateTime time;
        public Calibrate(DataBase m, string no,DateTime t)
        {
            this.md = m;
            this.DeviceNo = no;
            time = t;
            Cvalue = GetValue();
        }
        private DataTable GetValueDable()
        {
            string sql = "select [Time],[Calibrate] from [Calibration] where [DeviceNo]='"
                             + this.DeviceNo + "' order by [Time] desc";
            DataTable dt = md.GetDataSet(sql).Tables[0];
            return dt;
        }
        public bool IsDevicExist()
        {
            if (GetValueDable().Rows.Count == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        private double GetValue()
        {
            try
            {
              DataTable dt=GetValueDable();
                return (double)dt.Rows[0]["Calibrate"];
            }
            catch
            { return 0; }
        }

    }
}
